﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.AutomaticPathPlanner.Planner.CApAPPSegmentFullCTOCommand
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections.Generic;


namespace DnProcessSimulateCommands.AutomaticPathPlanner.Planner;

public class CApAPPSegmentFullCTOCommand : CApAPPSegmentCTOCommand
{
  private double m_fitnessGain;

  public CApAPPSegmentFullCTOCommand(
    CApAPPTask i_task,
    KiAppPathPlanningParamsEx i_pathPlanningParams)
    : base(i_task, i_pathPlanningParams)
  {
    this.m_fitnessGain = 0.0;
  }

  public double FitnessGain => this.m_fitnessGain;

  protected override bool DoStartPlanning(
    CApAPPTask i_task,
    KiAppPathPlanningParamsEx i_params,
    ref bool o_shouldContinue,
    ref List<string> o_errorMessages)
  {
    return KiAppSegmentOptimizeTrajectoryCommandEx.StartOptimize(i_task.KiTask, i_params, ref o_shouldContinue, ref o_errorMessages);
  }

  protected override void DoEndPlanning(CApAPPTask i_task, bool i_success)
  {
    this.m_fitnessGain = KiAppSegmentOptimizeTrajectoryCommandEx.EndOptimizeAndGetFitnessGain(i_task.KiTask, i_success);
  }

  protected override bool DoContinuePlanning(CApAPPTask i_task, ref bool o_shouldContinue)
  {
    return KiAppSegmentOptimizeTrajectoryCommandEx.ContinueOptimize(i_task.KiTask, ref o_shouldContinue);
  }

  protected override double DoGetProgress(CApAPPTask i_task)
  {
    return KiAppSegmentOptimizeTrajectoryCommandEx.GetProgress(i_task.KiTask);
  }

  public bool GetCurrentGain(
    ref int o_currentSegmentIndex,
    ref double o_currentSegmentGain,
    ref double o_globalGain)
  {
    return KiAppSegmentOptimizeTrajectoryCommandEx.GetCurrentGain(this.taskToPlan.KiTask, ref o_currentSegmentIndex, ref o_currentSegmentGain, ref o_globalGain);
  }
}
